<template>
  <div>
    <i class="el-icon-edit-outline" @click="createSeaAirMerge"></i>

    <CreateMergeEdit
      ref="CreateMergeEdit"
      :waybillId="data['id']"
    ></CreateMergeEdit>
  </div>
</template>

<script>
import { ajax, actionPermission } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";
import { m } from "@/store/yg/common/local";

const CreateMergeEdit = () => import("./editpage/CreateMergeEdit");

export default {
  components: {
    CreateMergeEdit
  },
  data() {
    return {};
  },
  props: ["row", "data", "more"],
  computed: {
    displayRules() {
      var rules = {};
      var uri = "/waybill/seafreightmerge/list";
      if (this.shippingWay == "AIR" || this.shippingWay == "ZX") {
        uri = "/waybill/airfreightmerge/list";
      } else if (this.shippingWay == "LCL" || this.shippingWay == "FCL") {
        var uri = "/waybill/seafreightmerge/list";
      }
      if (
        !this.$store.state.main.entry ||
        this.$store.state.main.entry.uri != uri
      ) {
        let mainUri = "/api/entry/main?uri=" + uri;
        new Promise((resolve, reject) => {
          axios
            .post(constant.API_SERVER + mainUri)
            .then(response => {
              response.data.table.action.forEach(element => {
                if (element.displayRule) {
                  rules[element.client.commit] = element.displayRule;
                }
              });
              resolve(response.data);
            })
            .catch(error => {
              reject(error);
            });
        });
      } else {
        for (var i in this.$store.state.main.entry.table.action) {
          let a = this.$store.state.main.entry.table.action[i];
          if (a.displayRule) {
            rules[a.client.commit] = a.displayRule;
          }
        }
      }
      return rules;
    }
  },
  mounted() {},
  methods: {
    // 初始化 下载

    createSeaAirMerge() {
      this.$refs.CreateMergeEdit.centerDialogVisible = true;
    }
  }
};
</script>

<style lang="scss" scoped>
.menu-list {
  min-width: 12vw;
  max-height: 90vh;
  overflow-y: auto;
  div {
    padding: 6px 8px;
    cursor: pointer;
    font-size: 12px;
    &:hover {
      background: #51abd1;
      color: #fff;
    }
  }
}
.letter {
  letter-spacing: -2px;
}
.icon-border {
  display: inline-block;
  border: 1px solid;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
}
</style>
